using System;
using System.Xml.Serialization;

namespace Pdf2epub.Model
{
    public class FontAssignmentData : BaseObject, IComparable
    {
        private FontUsage m_FontUsage;
        private string m_HtmlReplacementStyle;

        [XmlIgnore]
        public string FontName
        {
            get { return string.Format("{0} ({1})", FontUsage.FontName, FontUsage.FontSize); }
        }

        public FontUsage FontUsage
        {
            get { return m_FontUsage; }
            set
            {
                m_FontUsage = value;
                OnPropertyChanged("FontUsage");
                OnPropertyChanged("FontName");
                OnPropertyChanged("Occurance");
            }
        }

        public string HtmlReplacementStyle
        {
            get { return m_HtmlReplacementStyle; }
            set
            {
                m_HtmlReplacementStyle = value;
                OnPropertyChanged("HtmlReplacementStyle");
            }
        }

        [XmlIgnore]
        public int Occurance
        {
            get { return m_FontUsage.UsageCount; }
            set { m_FontUsage.UsageCount = value; }
        }

        public int CompareTo(object obj)
        {
            FontAssignmentData otherObject = obj as FontAssignmentData;
            if (otherObject == null)
                return -98;

            return FontUsage.CompareTo(otherObject.FontUsage);
        }
    }
}